home *** CD-ROM | disk | FTP | other *** search
/ Young Minds / Young Minds Interactive CD-ROM.ISO / mpss / collisio.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-07-20  |  3.6 KB  |  161 lines

  1.  
  2. /*******************************************************************************
  3. ********************************************************************************
  4. ********************************************************************************
  5.  
  6. PERMISSION TO COPY THIS SOFTWARE IS HEREBY GIVEN BY THE AUTHOR PROVIDED THAT
  7. THIS LEADING MESSAGE IS INCLUDED IN ALL OF THE RELEVANT SOURCE FILES.
  8.  
  9.         P. SCHMITZ, UNIVERSITY OF KEELE, MAY 1988.
  10.  
  11.  
  12. ********************************************************************************
  13. ********************************************************************************
  14. *******************************************************************************/
  15. #include "header.h"
  16.  
  17. collision(cp,c)
  18. register struct player *cp;
  19. char c;
  20. {
  21. /*check for any collisions*/
  22. switch (c)
  23.     {
  24.     
  25. case '@' :
  26.     {
  27.     plot1(cp,"You were sucked into a black hole and whirled out again. ");
  28.     plot2(cp,"This means your weapons have been damaged.   Better dock!");
  29.     cp->phaserbanks=0;
  30.     cp->photontorpedos=0;
  31.     plotphaserbanks(cp);
  32.     plotphotontorpedos(cp);
  33.     if (cp->stat!=5) plotstatus(cp,4);
  34.     break;
  35.     }
  36. case 'O' :
  37.     {
  38.     plot1(cp,"   You  crashed  into  a planet.  Oh  dear,  Oh  dear,   ");
  39.     plot2(cp,"   The crater you left was 12 miles wide. Your'e Dead!   ");
  40.     if (cp->reason>0) cp->reason= -1;
  41.     finish(cp);
  42.     break;
  43.     }
  44. case '.' :
  45.     {
  46.     cp->maxenergy -= 30;
  47.     cp->energy -= 30;
  48.     plotenergy(cp);
  49.     plotmaxenergy(cp);
  50.     plot1(cp,"    You collided with a star. Warp capability has been   ");
  51.     plot2(cp,"    reduced by 30, and your  energy  is  30 lower now.   ");
  52.     if (cp->stat!=5) plotstatus(cp,4);
  53.     break;
  54.     }
  55. case 'k' :
  56.     {
  57.     cp->maxenergy -= 100;
  58.     cp->energy -= 100;
  59.     plotenergy(cp);
  60.     plotmaxenergy(cp);
  61.     plot1(cp,"    You collided with a klingon mevisic mine...          ");
  62.     plot2(cp,"    Energy and Maxenergy have dropped by 100.            ");
  63.     if (cp->stat!=5) plotstatus(cp,4);
  64.     break;
  65.     }
  66. case '#' :
  67.     {
  68.     cp->maxenergy -= 400;
  69.     cp->energy -= 400;
  70.     plotenergy(cp);
  71.     plotmaxenergy(cp);
  72.     plot1(cp,"    You collided with a Romulan Warning buoy.            ");
  73.     plot2(cp,"    Energy and Maxenergy have dropped by 400.            ");
  74.     if (cp->stat!=5) plotstatus(cp,4);
  75.     break;
  76.     }
  77. case 'o' :
  78.     {
  79.     if (cp->doneit==1) 
  80.     {
  81.     plot1(cp,"    You CANNOT try that again you moron!!! That would    ");
  82.     plot2(cp,"    allow anyone to get any score.....bye bye........    ");
  83.     if (cp->reason>0) cp->reason= -5;
  84.     finish(cp);
  85.     break;
  86.     } else
  87.     {
  88.     cp->maxvel+=1;
  89.     cp->score+=100;
  90.     plotscore(cp);
  91.     cp->maxphaser += 10;
  92.     cp->maxphoton += 10;
  93.     cp->photonpower +=20;
  94.     cp->phaserpower += 20;
  95.     cp->phaserreach +=5;
  96.     cp->photonreach +=5;
  97.     plotphaserbanks(cp);
  98.     plotphotontorpedos(cp);
  99.     cp->doneit=1;
  100.     cp->maxenergy += 110;
  101.     cp->energy += 110;
  102.     plotenergy(cp);
  103.     plotmaxenergy(cp);
  104.     plot1(cp," You fell through a time warp.  Just look what this has  ");
  105.     plot2(cp," done to your ship. You obviously went into the future!! ");
  106.     break;
  107.     }
  108.     }
  109. default : break;
  110.     }
  111. }
  112.  
  113. finish(x)
  114. register struct player *x;
  115. {
  116. struct player *r;
  117.  
  118. if (x->stat<12)
  119.     {
  120.     x->chflg=FLAG;
  121.     fire_torpedo(x,'1',1);
  122.     fire_torpedo(x,'2',1);
  123.     fire_torpedo(x,'3',1);
  124.     fire_torpedo(x,'4',1);
  125.     fire_torpedo(x,'8',1);
  126.     fire_torpedo(x,'6',1);
  127.     fire_torpedo(x,'7',1);
  128.     fire_torpedo(x,'9',1);
  129.     plotstatus(x,12);
  130.     x->messindex= -1;
  131.     }
  132. if (x->id!=ROMID && x->id!=KLINGID)
  133.     {
  134.     beep(x);
  135.     beep(x);
  136.     }
  137. }
  138.  
  139. which_sector(x,y,xv,yv)
  140. int x,y,xv,yv;
  141. {
  142.     x+=xv;
  143.     x+=xv;
  144.     y+=yv;
  145.     y+=yv;
  146.     if ((x<58)||(x>899)||(y<19)||(y>899)) return(0);
  147.     if ((x>450)&&(x<899))
  148.         {
  149.         if ((y<450)&&(y>19)) return(4);
  150.         else 
  151.         if ((y>450)&&(y<899)) return(2);
  152.         }
  153.     if ((x<450)&&(x>58))
  154.         {
  155.         if ((y>450)&&(y<899)) return(1);
  156.         else 
  157.         if ((y<450)&&(y>19)) return(3);
  158.         }
  159. }
  160.  
  161.